package com.ele.ui;

import java.util.Scanner;

import com.ele.pojo.Admin;
import com.ele.service.AdminService;

public class AdminUI {
	private static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		System.out.println("================");
		System.out.println("\t管理员界面");
		System.out.println("================");
		login(); 
		ShopManagerUI();
	}
	/**
	 * 	登入界面
	 */
	private static void login() {
		System.out.println("请输入账号：");
		String admin = sc.nextLine();
		System.out.println("请输入密码：");
		String password = sc.nextLine();
		AdminService adminService = new AdminService();
		Admin flag = adminService.adminLogin(admin,password);
		if (flag==null) {
			System.out.println("账号或密码不正确");
			login();
		}else {
			System.out.println("管理商铺界面");
		}
	}
	/**
	 * 	管理员对商铺进行管理
	 */
	public static void ShopManagerUI() {
		System.out.println("1.添加商铺"+"2.查询商铺"+"3.修改商铺");
		Integer input = sc.nextInt();
		AdminManager shopManager = new AdminManager();
		if (input == 1) {
			shopManager.addShop();
		}else if (input == 2) {
			shopManager.selectShop();
		}else if (input == 3) {
			shopManager.updateShop();
		}else {
			System.out.println("是否退出？y/n");
			if (sc.nextLine().equalsIgnoreCase("y")) {
				return;
			}
		}
		ShopManagerUI();
	}
}
